import React from 'react'
import { forwardRef, useImperativeHandle } from 'react';

import { useState,useReducer } from 'react';

const Demo = forwardRef(function Demo(props, ref) {
    const [btnState, btnStateSet] = useReducer((state,action)=>({...state,...action}), {
        btn1:true,
        btn2:true,
        btn3:true
    })
    useImperativeHandle(ref, () => {
        return {
            btnStateSet,
            btnState,
        };
    }, []);
    return (
        <div>
            <button disabled={btnState.btn1}>btn1</button>
            <button disabled={btnState.btn2}>btn2</button>
            <button disabled={btnState.btn3}>btn3</button>
        </div>
    )    
})

export default Demo





